package com.jinzhi.jzweb.controller;


import java.util.*;

import com.jinzhi.jzweb.domain.JazUserCommentClassifyDO;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.jinzhi.common.annotation.Log;
import com.jinzhi.common.base.BaseController;
import com.jinzhi.jzweb.domain.JazUserCommentDescriptionDO;
import com.jinzhi.jzweb.service.JazUserCommentDescriptionService;
import com.jinzhi.common.utils.Result;

/**
 * 
 * <pre>
 * 评价描述表
 * </pre>
 * <small> 2024-05-16 15:08:53 | Long</small>
 */
@Controller
@RequestMapping("/jazUserCommentDescription")
public class JazUserCommentDescriptionController extends BaseController {
	@Autowired
	private JazUserCommentDescriptionService jazUserCommentDescriptionService;
	
	@GetMapping()
	@RequiresPermissions("jzweb:jazUserCommentDescription:jazUserCommentDescription")
	String JazUserCommentDescription(){
	    return "jzweb/jazUserCommentDescription/jazUserCommentDescription";
	}

	/**
	 * 分页查询评价描述表
	 * @param
	 * @return
	 */
	@ResponseBody
	@GetMapping("/list")
	@RequiresPermissions("jzweb:jazUserCommentDescription:jazUserCommentDescription")
	public Result<Page<JazUserCommentDescriptionDO>> list(@RequestParam int pageNumber,@RequestParam int pageSize){
		return Result.ok(jazUserCommentDescriptionService.getUserCommentDescriptionList(pageNumber,pageSize));
	}

	/**
	 * 查询评价类型
	 * @param
	 * @return
	 */
	@ResponseBody
	@GetMapping("/getCommentType")
	public Result<List<JazUserCommentClassifyDO>> getCommentType(){
		return Result.ok(jazUserCommentDescriptionService.getCommentType());
	}
	
	@GetMapping("/add")
	@RequiresPermissions("jzweb:jazUserCommentDescription:add")
	String add(){
	    return "jzweb/jazUserCommentDescription/add";
	}

	@GetMapping("/edit/{id}")
	@RequiresPermissions("jzweb:jazUserCommentDescription:edit")
	String edit(@PathVariable("id") Long id,Model model){
		JazUserCommentDescriptionDO jazUserCommentDescription = jazUserCommentDescriptionService.selectById(id);
		model.addAttribute("jazUserCommentDescription", jazUserCommentDescription);
	    return "jzweb/jazUserCommentDescription/edit";
	}

	/**
	 * 根据id查询评价描述
	 * @param id
	 * @return
	 */
	@ResponseBody
	@GetMapping("/selectById")
	public Result selectUserCommentDescriptionById(@RequestParam("id") Long id){
		return Result.ok(jazUserCommentDescriptionService.selectUserCommentDescriptionById(id));
	}

	@Log(value = "修改状态",sysModule = 8,operationType = 3)
	@PostMapping( "/updateUserCommentDescription")
	@ResponseBody
	public Result<String> updateUserCommentDescriptionStatus( @RequestBody JazUserCommentDescriptionDO jazUserCommentDescriptionDO){
		return jazUserCommentDescriptionService.updateUserCommentDescriptionStatus(jazUserCommentDescriptionDO);
	}
	
	@Log(value = "添加评价描述",sysModule = 8,operationType = 1)
	@ResponseBody
	@PostMapping("/save")
	@RequiresPermissions("jzweb:jazUserCommentDescription:add")
	public Result<String> saveUserCommentDescription(@RequestBody JazUserCommentDescriptionDO jazUserCommentDescription){
        return jazUserCommentDescriptionService.saveUserCommentDescription(jazUserCommentDescription);
	}
	
	@Log(value = "修改评价描述",sysModule = 8,operationType = 3)
	@ResponseBody
	@RequestMapping("/update")
	@RequiresPermissions("jzweb:jazUserCommentDescription:edit")
	public Result<String>  update(@RequestBody JazUserCommentDescriptionDO jazUserCommentDescription){
		return jazUserCommentDescriptionService.updateUserCommentDescriptionById(jazUserCommentDescription);
	}
	
	@Log(value = "删除评价描述",sysModule = 8,operationType = 3)
	@PostMapping( "/remove")
	@ResponseBody
	@RequiresPermissions("jzweb:jazUserCommentDescription:remove")
	public Result<String>  remove( Long id){
		jazUserCommentDescriptionService.deleteById(id);
        return Result.ok();
	}
	
	@Log(value = "批量删除评价描述",sysModule = 8,operationType = 2)
	@PostMapping( "/batchRemove")
	@ResponseBody
	@RequiresPermissions("jzweb:jazUserCommentDescription:batchRemove")
	public Result<String>  remove(@RequestParam("ids[]") Long[] ids){
		jazUserCommentDescriptionService.deleteBatchIds(Arrays.asList(ids));
		return Result.ok();
	}
	
}
